load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_test")
load("//proto/prost:defs.bzl", "rust_prost_toolchain")
load("//rust:defs.bzl", "rust_library_group")
load(":prost.bzl", "RUST_EDITION", "current_prost_runtime")

current_prost_runtime(
    name = "current_prost_runtime",
)

rust_binary(
    name = "protoc_wrapper",
    srcs = ["protoc_wrapper.rs"],
    edition = RUST_EDITION,
    visibility = ["//visibility:public"],
    deps = [
        ":current_prost_runtime",
        "@rules_rust_prost__heck//:heck",
    ],
)

rust_test(
    name = "protoc_wrapper_test",
    crate = ":protoc_wrapper",
    edition = RUST_EDITION,
)

bzl_library(
    name = "bzl_lib",
    srcs = glob(["**/*.bzl"]),
    visibility = ["//proto/prost:__pkg__"],
    deps = [
        "//proto/prost/private/3rdparty:bzl_lib",
    ],
)

rust_library_group(
    name = "prost_runtime",
    deps = [
        "//proto/prost/private/3rdparty/crates:prost",
    ],
)

rust_library_group(
    name = "tonic_runtime",
    deps = [
        ":prost_runtime",
        "//proto/prost/private/3rdparty/crates:tonic",
    ],
)

rust_prost_toolchain(
    name = "default_prost_toolchain_impl",
    prost_plugin = "//proto/prost/private/3rdparty/crates:protoc-gen-prost__protoc-gen-prost",
    prost_plugin_flag = "--plugin=protoc-gen-prost=%s",
    prost_runtime = ":prost_runtime",
    prost_types = "//proto/prost/private/3rdparty/crates:prost-types",
    tonic_plugin = "//proto/prost/private/3rdparty/crates:protoc-gen-tonic__protoc-gen-tonic",
    tonic_plugin_flag = "--plugin=protoc-gen-tonic=%s",
    tonic_runtime = ":tonic_runtime",
)
